const sys = require(`./system.js`)
const $ = sys.$('助学账户信息-基本信息')

sys.run($, 'task:all', (resList, cookie, index, username, password, item) => {
    return new Promise(async resolve => {
        console.log('cookie', cookie)
        // 请求接口
        const info = await $.publicJS.userInfo($, cookie)
        // const boaInfo = await $.publicJS.boaInfo($, cookie)
        // const dungList = await publicJS.dungList($, cookie)
        // const belongInfo = await $.publicJS.belongInfo($, cookie)
        // const summary = await $.publicJS.getSummary($, cookie)
        // const queryRealName = await $.publicJS.queryRealName($, cookie)
        const queryRealNameAndType = await $.publicJS.queryRealNameAndType($, cookie)
        // const unclaimed = await $.publicJS.unclaimed($, cookie)
        // const bidList = await $.publicJS.bidList($, cookie, 1, 0)
        // const canTransferList = await $.publicJS.canTransferList($, cookie, 1)
        // console.log('item', queryRealNameAndType)
        
        // 构建 obj 信息
        resList.push({
            // ...item,
            username: username,
            password: password,
            "序号": index + 1,
            "id": info.id,
            "微信昵称": info.userWechatNickName,
            "实名": queryRealNameAndType.realNameAuthentication ? queryRealNameAndType.realNameAuthentication.realName : '无',
            "身份证号": queryRealNameAndType.realNameAuthentication ? queryRealNameAndType.realNameAuthentication.idNumber : '无',
            "账户全部资产": info.userUserCurrentAmount
        })
        resolve(resList)
    })
}, (resList) => {
    console.log('任务结束 resList:', resList)
    if (resList && resList.length > 0) {
        resList = resList.sort((a1, a2) => {
            return a1['序号'] - a2['序号']
        })
        // 存储列表
        $.localStorage.set('task:all', resList, 'localStorage')
    }
}, 1200)
